import { GLabel } from "../../../../../com/mui/controls/GLabel";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { TaskInfo } from "../../../model/TaskInfo";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { TaskConfig } from "../../../resource/TaskConfig";
type int = number;
//class TaskTreeNode
    
    export  class TaskTreeNode /* flash.display.Sprite */
    {
        constructor()
        {
            
            mouseChildren = false;
            buttonMode = true;
            this._label = new GLabel();
            addChild(this._label);
            this._label.height = 20;
            this._label.width = 140;
            this._label.styleName = "GLabel";
            this._overSkin = GlobalClass.getBitmap(ImagesConst.PopUpMenuOverSkin);
            addEventListener(flash.events.MouseEvent.MOUSE_OVER, this.onMouseOver);
            addEventListener(flash.events.MouseEvent.MOUSE_OUT, this.onMouseOut);
            return;
        }

        public get task(): TaskInfo
        {
            return this._task;
        }

        public get taskId(): int
        {
            return this._taskId;
        }

        public initTask(arg1: TaskInfo): void
        {
            this._taskId = arg1.sTask.code;
            this._task = arg1;
            this._label.htmlText = HTMLUtil.addColor(TaskConfig.instance.getTaskName(arg1.sTask.code), arg1.taskNameColor) + arg1.isCompleted;
            return;
        }

        public updateTask(arg1: TaskInfo): void
        {
            this._taskId = arg1.sTask.code;
            this._task = arg1;
            this._label.htmlText = TaskConfig.instance.getTaskName(arg1.sTask.code) + arg1.isCompleted;
            return;
        }

        public selected(): void
        {
            this._selected = true;
            removeEventListener(flash.events.MouseEvent.MOUSE_OVER, this.onMouseOver);
            removeEventListener(flash.events.MouseEvent.MOUSE_OUT, this.onMouseOut);
            return;
        }

        public unSelected(): void
        {
            this._selected = false;
            if (this._overSkin.parent) 
            {
                removeChild(this._overSkin);
            }
            addEventListener(flash.events.MouseEvent.MOUSE_OVER, this.onMouseOver);
            addEventListener(flash.events.MouseEvent.MOUSE_OUT, this.onMouseOut);
            return;
        }

        public dispose(): void
        {
            this.unSelected();
            this._task = null;
            return;
        }

        /* internal  */onMouseOver(arg1: Object /* flash.events.MouseEvent */): void
        {
            addChildAt(this._overSkin, 0);
            return;
        }

        /* internal  */onMouseOut(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._overSkin.parent) 
            {
                removeChild(this._overSkin);
            }
            return;
        }

        public /* override */ get height(): number
        {
            return this._label.height;
        }

        /* internal */ /* var */_label: GLabel;

        /* internal */ /* var */_task: TaskInfo;

        /* internal */ /* var */_taskId: int;

        /* internal */ /* var */_selected: Boolean;

        /* internal */ /* var */_overSkin: Object /* flash.display.Bitmap */;
    }
